﻿Imports System.Xml

Public Class searchSeriesFrm
    Private _selSeries As String

    Public ReadOnly Property SelectedSeries As String
        Get
            Return _selSeries
        End Get
    End Property

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim searchResults As XmlNodeList

        seriesList.Items.Clear()
        seriesList.Items.Add("Searching...")
        Application.DoEvents()

        searchResults = searchTVDb(0, seriesNameTxt.Text)

        seriesList.Items.Clear()

        Dim series As XmlNode

        If searchResults.Count = 0 Then
            seriesList.Items.Add("No results found!")
        End If

        For Each series In searchResults
            seriesList.Items.Add(makeMD5("tvdb" & series.Item("seriesid").InnerText), series.Item("SeriesName").InnerText, 0)
        Next

    End Sub

    Private Sub browseClick(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub seriesAddBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles seriesAddBtn.Click
        _selSeries = seriesList.SelectedItems(0).Name
        Me.DialogResult = vbOK
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.DialogResult = vbCancel
        Me.Close()
    End Sub
End Class
